<template>
  <div>
    <div>
        <input type="file" @change="imgChange" accept=".gif,.jpg,.jpeg,.png">
    </div>
    <img id="showImage" :src="baseImg" alt="">
  </div>
</template>
<script>
export default {
  data () {
    return {
      baseImg: ''
    }
  },
  methods: {
    imgChange(e) {
      const self = this
      // var dom =$("input[id^='imgTest']")[0]
      // console.info(dom.value)//这个是文件的路径 C:\fakepath\icon (5).png
      var reader = new FileReader()
      reader.onload = (function (file) {
          return function (e) {
            self.baseImg = this.result
          }
      })(e.target.files[0])
      reader.readAsDataURL(e.target.files[0])
    }
  }
}
</script>
